package br.com.octobite.cashkeeper;

import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

public class CashKeeperActivity extends Activity {

	public static final String TAG = "CASH_KEEPER";
	private TextView dataHoje;
	private TextView valorTotalHoje;
	private Locale locale;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_cash_keeper);
		dataHoje = (TextView) findViewById(R.id.data);

		locale = getResources().getConfiguration().locale;

		Log.i(TAG, locale.getCountry());

		SimpleDateFormat df = new SimpleDateFormat();
		if (locale.getCountry().equals("US")) {
			df.applyPattern("MM/dd/yyyy");
		} else {
			df.applyPattern("dd/MM/yyyy");
		}
		Calendar c = Calendar.getInstance();

		dataHoje.setText(df.format(c.getTime()));

		valorTotalHoje = (TextView) findViewById(R.id.valor_dia);

		// TODO buscar valor existente para o dia se houver
		valorTotalHoje.setText(formataValor(1000.00));
		
		
	}

	private String formataValor(double valor) {

		return NumberFormat.getCurrencyInstance(locale).format(valor);
	}

	// Para a tela de inser��o de valores para o dia
	public void inserirValor(View v) {
		Intent intent = new Intent(this, CadastraGastosActivity.class);
		startActivity(intent);
	}

	// Para tela de visualiza��o dos gastos do dia
	public void vizualizarGastos(View v) {
		
		Intent intent = new Intent(this, ListaGastosActivity.class);
		startActivity(intent);
	}

}
